<?php
	if ($_POST)
	{
		require('config.php');
        $listname = $_POST["listname"];
		if (isset($_COOKIE['userid']) && $_COOKIE['userid'] != '')
		{
			$time = date("Y-m-d H:i:s");
            $stmt = $connection->prepare('insert into user_fav_lists (user_id, fav_type, create_time) values (?, ?, ?)');
            $stmt->bind_param("sss", $_COOKIE['userid'], $listname, $time);
            $stmt->execute();
            if ($stmt->affected_rows != 1)
            {
                echo "LISTEXIST";
            }
            else
            {
                echo $time;
            }
		}
		else
		{
			echo "NOUSER";	
		}
        $connection->close();
	}
	else
	{
		echo "NOPOST";	
	}
?>
